const { VantResolver } = require('@vant/auto-import-resolver');
const ComponentsPlugin = require('unplugin-vue-components/webpack');
const { execSync } = require('child_process');
const dayjs = require('dayjs');

const nowTime = dayjs().format('YYYYMMDD_HHmm');
const GIT_HASH = execSync('git rev-parse HEAD').toString().trim();
const suffix = nowTime + '.' + GIT_HASH;

console.log(suffix, 'suffix');

module.exports={
    css:{
        loaderOptions:{
            postcss:{
                plugins:[
                    require('postcss-px2rem-exclude')({
                        remUnit:37.5,
                        exclude:/node_moudule/
                    })
                ]
            }
        }
    },
    devServer:{
        host:"fkh5.gxjiankang.cn",
        port: 80,
        proxy:{
            '/api':{
                target:'https://fkadmin.gxjiankang.cn/prod-api',
                changeOrigin:true,
                pathRewrite:{
                    '^/dev-api':''
                }
            }
        }
    },
    configureWebpack: {
        plugins: [
          ComponentsPlugin({
            resolvers: [VantResolver()],
          }),
        ],
        output: {
          filename: `js/[name].${suffix}.js`,
          chunkFilename: `js/[name].${suffix}.js`
        },
      }
}